<template>
  <div class="container">
    <el-form ref="form" :model="form" label-width="80px">

      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="货品名称">
            <el-input v-model="form.goodsName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="存储单位">
            <el-select v-model="form.unit" placeholder="请选择">
              <el-option
                  v-for="item in units"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="12">
          <el-form-item label="货品重量">
            <el-input-number v-model="form.weight" controls-position="right"  :min="1" :max="999999" :step="0.1"></el-input-number>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="重量单位">
            <el-select v-model="form.weightUnit" placeholder="请选择">
              <el-option
                  v-for="item in weights"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex">
        <el-col :span="8">
          <el-form-item label="成本价">
            <el-input-number v-model="form.goodsCostPrice" controls-position="right"  :min="1" :max="999999" :step="0.1"></el-input-number>
          </el-form-item>

        </el-col>
        <el-col :span="8">

          <el-form-item label="销售价">
            <el-input-number v-model="form.goodsSalesPrice" controls-position="right"  :min="1" :max="999999" :step="0.1"></el-input-number>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="供应商">
            <el-select v-model="form.supplier" placeholder="请选择">
              <el-option
                  v-for="item in supplierList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>



      <el-row type="flex">
        <el-col :span="8">
          <el-form-item label="货品类型">
            <el-select v-model="form.goodsType" placeholder="请选择">
              <el-option
                  v-for="item in goodsTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="是否启用">
            <el-switch v-model="form.status"></el-switch>
          </el-form-item>
        </el-col>
        <!--       状态-->
        <el-col :span="8">
          <el-form-item label="销售方式">
            <el-radio v-model="form.salesType" label="0">按件</el-radio>
            <el-radio v-model="form.salesType" label="1">按重量</el-radio>
          </el-form-item>
        </el-col>
        <!--       单位-->

      </el-row>

<!--      <el-form-item>-->
<!--        <el-button type="primary" @click="sumbmit">添加</el-button>-->
<!--        <el-button @click="canceAdd">取消</el-button>-->
<!--      </el-form-item>-->
    </el-form>
  </div>
</template>

<script>
export default {
  name: "updateGoods",
  data(){
    return {
      form:{
        id:'',
        goodsName:"",
        goodsCostPrice:'',
        goodsSalesPrice:'',
        isPiece:'',
        isWeight:'',
        weight:null,
        unit:'',
        salesType:"1",
        goodsType:null,
        status:true,
        supplier:null,
        weightUnit:''
      },
      goodsTypeList:[],
      supplierList:[],
      units: [{
        value: '部',
        label: '部'
      }, {
        value: '件',
        label: '件'
      }, {
        value: '个',
        label: '个'
      }
        ,{
          value: '包',
          label: '包'
        },
        {
          value: '箱',
          label: '箱'
        },
        {
          value: '瓶',
          label: '瓶'
        }
      ],
      weights:[
        {
          value:'克',
          label:'克',
        },
        {
          value: '千克',
          label: "千克"
        }
      ]
    }
  },
  mounted() {
    this.$bus.$on('updateGoods',(form,supplierList,goodsTypeList)=>{
      //先绚烂
      this.form=form;
      this.supplierList=supplierList;
      this.goodsTypeList=goodsTypeList;
    })
  }
}
</script>

<style scoped>

</style>